#pragma once
#include <d3dx9.h>
#include "D3D9Define.h"
#include "GpuProgram.h"
#include "D3D9Device.h"
using namespace DreamEngine;

namespace DreamEngineD3D
{

class _EngineD3D9Export CD3D9HLSLProgram : public CGpuProgram
{
public: 

	CD3D9HLSLProgram(CD3D9Device* pD3D9Device, ShaderProfile profile);
	~CD3D9HLSLProgram();

protected:

	virtual Error				LoadFromFile(const CString& fileName, const CString& enterFun);
	virtual Error				CreateParamTable(void);
	virtual	void				UpdateAutoParams(void);
	virtual void				UpdateParams(void);

protected:

	LPD3DXBUFFER				m_pShaderBuffer;
	LPD3DXBUFFER				m_pErrorBuffer;
	LPD3DXCONSTANTTABLE			m_pConstantTable;

	CD3D9Device*				m_pD3D9Device;
};

class _EngineD3D9Export CD3D9HLSLFragment : public CD3D9HLSLProgram
{
public:
	CD3D9HLSLFragment(CD3D9Device* pD3D9Device, ShaderProfile profile=SP_PS_2_0);
	~CD3D9HLSLFragment(void);

	IDirect3DPixelShader9*	GetD3D9Shader(void)const		{return m_pShader;}

protected:

	virtual Error			CreateShader(void);

	IDirect3DPixelShader9*	m_pShader;
};

class _EngineD3D9Export CD3D9HLSLVertex : public CD3D9HLSLProgram
{

public:

	CD3D9HLSLVertex(CD3D9Device* pD3D9Device, ShaderProfile profile=SP_VS_2_0);
	~CD3D9HLSLVertex(void);

	IDirect3DVertexShader9*		GetD3D9Shader(void)const		{return m_pShader;}

protected:

	IDirect3DVertexShader9*		m_pShader;

protected:

	virtual Error			CreateShader(void);
};

}


